import Vue from 'vue'
import VueRouter from 'vue-router'
import NProgress from 'nprogress' // 进度条
import 'nprogress/nprogress.css'
import {vantRouter} from "@/router/vant-router"; //这个样式必须引入
// 注册路由插件
Vue.use(VueRouter)

const dynamicImport = 'index'
//
export const routes = [
  {
    path: '/',
    component: () => import(`@/EmptyHome.vue`),
    meta: {
      title: '空首页'
    }
  },
  {
    path: '/index',
    component: () => import(`@/views/index/${dynamicImport}.vue`),
    // component: () => import('@/views/index/index.vue'),
    meta: {
      title: '首页'
    }
  },
  {
    path: '/dynamicTable',
    component: () => import('@/views/dynamicTable/' + dynamicImport + '.vue'),
    // component: () => import('@/views/dynamicTable/index.vue'),
    meta: {
      title: '动态表格'
    }
  },
  {
    path: '/selectObject',
    component: (resolve) => require([`@/views/select-object/${dynamicImport}`], resolve),
    // component: () => import('@/views/select-object/index.vue'),
    meta: {
      title: '选择对象'
    }
  },
  {
    path: '/dynamicForm',
    // component: (resolve) =>  require([`@/views/dynamic-form/index.vue`], resolve),
    // component: () => import(`@/views/dynamic-form/index.vue`),
    component: () => import('@/views/dynamic-form/index.vue'),
    meta: {
      title: '动态表单'
    },
  },
  {
    path: '/dynamicForm-template',
    component: () => import('@/views/dynamic-form-template/index.vue'),
    meta: {
      title: '动态表单-template'
    },
  },
  {
    path: '/forForm',
    component: () => import('@/views/forForm/index.vue'),
    meta: {
      title: '循环表单'
    },
  },
  {
    path: '/mui-player-nocomtrols.vue',
    component: () => import('@/views/MuiPlayer/index.vue'),
    meta: {
      title: 'muiPlayer'
    },
  },
  {
    path: '/BigScreenTitle1',
    component: () => import('@/views/BigScreen/Title1/index.vue'),
    meta: {
      title: 'BigScreenTitle1',
      notShowMenu: true
    },
  },
  {
    path: '/textEllipsis',
    component: () => import('@/views/textEllipsis/index.vue'),
    meta: {
      title: '文字溢出',
    },
  },
  {
    path: '/Elevator',
    component: () => import('@/views/Elevator/index.vue'),
    meta: {
      title: '电梯组件',
    },
  },
  {
    path: '/limitPromise',
    component: () => import('@/views/limitPromise/index.vue'),
    meta: {
      title: 'promise数量控制',
    },
  },
  {
    path: '/antiShakeThrottling',
    component: () => import('@/views/antiShakeThrottling/index.vue'),
    meta: {
      title: '防抖节流',
    },
  },
  {
    path: '/utils',
    component: () => import('@/views/utils/index.vue'),
    meta: {
      title: '工具',
    },
  },
  {
    path: '/callApp',
    component: () => import('@/views/callApp/index.vue'),
    meta: {
      title: '调用app',
    },
  },
  {
    path: '/callMapFunction',
    component: () => import('@/views/callMapFunction/index.vue'),
    meta: {
      title: '调用地图功能',
    },
  },
  {
    path: '/loading',
    component: () => import('@/views/loading/index.vue'),
    meta: {
      title: '各种loading',
    },
  },
  {
    path: '/directiveMap',
    component: () => import('@/views/directiveMap/index.vue'),
    meta: {
      title: '指令合集',
    },
  },
  {
    path: '/combinationKey',
    component: () => import('@/views/combinationKey/index.vue'),
    meta: {
      title: '组合键',
    },
  },
  {
    path: '/ImageCropping',
    component: () => import('@/views/ImageCropping/index.vue'),
    meta: {
      title: '图片裁剪',
    },
  },
  {
    path: '/printDemo',
    component: () => import('@/views/printDemo/index.vue'),
    meta: {
      title: '打印调用',
    },
  },
  {
    path: '/CertificateGenerator',
    component: () => import('@/views/CertificateGenerator/index.vue'),
    meta: {
      title: '证书生成器',
    },
  },
  {
    path: '/echarts',
    component: () => import('@/views/echarts/index.vue'),
    meta: {
      title: '常用的echarts',
    },
  },
  {
    path: '/vxeTable',
    component: () => import('@/views/vxeTable/index.vue'),
    meta: {
      title: 'vxeTable',
    },
  },
  {
    path: '/rust-wasm',
    component: () => import('@/views/rustWasm/index.vue'),
    meta: {
      title: 'rust-wasm',
    },
  },
  {
    path: '/svg-icon',
    component: () => import('@/views/svgIcon/index.vue'),
    meta: {
      title: 'svg封装使用',
    },
  },
  {
    path: '/print-js',
    component: () => import('@/views/printJs/index.vue'),
    meta: {
      title: '调用打印机',
    },
  },
  {
    path: '/code-edit',
    component: () => import('@/views/CodeEdit/index.vue'),
    meta: {
      title: '代码编辑',
    },
  },
  {
    path: '/knowledge-game',
    component: () => import('@/views/knowledgeGame/index.vue'),
    meta: {
      title: '知识游戏',
    },
  },
  {
    path: '/vant-router',
    component: () => import('@/views/VantRouter/index.vue'),
    meta: {
      title: 'vantRouter'
    },
    children: vantRouter
  },
  {
    path: '/func-com',
    component: () => import('@/views/funcCom/index.vue'),
    meta: {
      title: '函数单文件',
    },
  },
  {
    path: '/BrowseVueLoader',
    component: () => import('@/views/BrowseVueLoader/index.vue'),
    meta: {
      title: '浏览器直接解析vue文件',
    },
  },
  {
    path: '/Book',
    component: () => import('@/views/Book/index.vue'),
    meta: {
      title: '我写的vueTurn',
    },
  },
  {
    path: '/cssTable',
    component: () => import('@/views/cssTable/index.vue'),
    meta: {
      title: 'cssTable',
    },
  },
]

const router = new VueRouter({
  routes
})
NProgress.inc(0.2)
NProgress.configure({easing: 'ease', speed: 500, showSpinner: false})
router.beforeEach(async (to, from, next) => {
  NProgress.start()
  next()
})
router.afterEach(() => {
  NProgress.done()
})
export default router
